/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = 7);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.EventNames = void 0;
var EventNames;
(function (EventNames) {
    EventNames[EventNames["TAP"] = 0] = "TAP";
    EventNames[EventNames["ROLE_FREEZING"] = 1] = "ROLE_FREEZING";
    EventNames[EventNames["UPDATE_JOB_TEXT"] = 2] = "UPDATE_JOB_TEXT";
    EventNames[EventNames["UPDATE_STATUS_TEXT"] = 3] = "UPDATE_STATUS_TEXT";
    EventNames[EventNames["IS_INGAME"] = 4] = "IS_INGAME";
    EventNames[EventNames["SHOW_MENU_DIALOG"] = 5] = "SHOW_MENU_DIALOG";
    EventNames[EventNames["START"] = 6] = "START";
    EventNames[EventNames["LOAD_ASSETS_COMPLETE"] = 7] = "LOAD_ASSETS_COMPLETE";
})(EventNames = exports.EventNames || (exports.EventNames = {}));


/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __spreadArrays = (this && this.__spreadArrays) || function () {
    for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
    for (var r = Array(s), k = 0, i = 0; i < il; i++)
        for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
            r[k] = a[j];
    return r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var EventNames_1 = __webpack_require__(0);
var EventBus = (function () {
    function EventBus() {
    }
    EventBus.on = function (eventName, listener) {
        return this.emitter.on(EventNames_1.EventNames[eventName], listener);
    };
    EventBus.once = function (eventName, listener) {
        return this.emitter.once(EventNames_1.EventNames[eventName], listener);
    };
    EventBus.emit = function (eventName) {
        var _a;
        var args = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            args[_i - 1] = arguments[_i];
        }
        return (_a = engines.myEngine()).emit.apply(_a, __spreadArrays([EventNames_1.EventNames[eventName]], args));
    };
    EventBus.removeAllListeners = function (eventName) {
        return this.emitter.removeAllListeners(EventNames_1.EventNames[eventName]);
    };
    EventBus.removeListener = function (eventName, listener) {
        return this.emitter.removeListener(EventNames_1.EventNames[eventName], listener);
    };
    EventBus.emitter = events;
    return EventBus;
}());
exports.default = EventBus;


/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.Assets = void 0;
exports.Assets = {
    images: {
        img_skip: {
            region: [1700, 58]
        },
        img_skip2: {
            region: [1754, 17]
        },
        btn_quick_use: {
            alpha: true,
            region: [1459, 475]
        },
        btn_show_map: {
            alpha: true,
            region: [1722, 247]
        },
        img_dialog_close: {
            region: [1839, 27],
            findbtn: {
                color: "#b5ffff",
                points: [
                    [1317, 620],
                    [1317, 713],
                    [1317, 800]
                ]
            }
        },
        img_zi: {
            alpha: true,
            region: [843, 892]
        },
    }
};


/***/ }),
/* 3 */
/***/ (function(module, exports) {

var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var bt;
(function (bt) {
    bt.version = '1.1.0';
    var BehaviorTree = (function () {
        function BehaviorTree() {
        }
        return BehaviorTree;
    }());
    bt.BehaviorTree = BehaviorTree;
})(bt || (bt = {}));
var bt;
(function (bt) {
    var BlackBoard = (function () {
        function BlackBoard() {
            this.btMethod = {};
            this.content = {};
        }
        BlackBoard.create = function () {
            return new bt.BlackBoard();
        };
        BlackBoard.prototype.clear = function () {
            this.content = {};
            this.btMethod = {};
        };
        return BlackBoard;
    }());
    bt.BlackBoard = BlackBoard;
})(bt || (bt = {}));
var bt;
(function (bt) {
    var BaseNode = (function () {
        function BaseNode() {
            this.name = 'Node';
            this.hashid = 0;
            this.hashid = BaseNode.hashid++;
        }
        BaseNode.prototype.precondition = function (input) {
            if (this.condition) {
                return this.condition.execute(input);
            }
            return true;
        };
        BaseNode.prototype.tick = function (input) {
            if (!this.precondition(input)) {
                return 1;
            }
            return this.execute(input);
        };
        BaseNode.prototype.execute = function (input) {
            return 1;
        };
        BaseNode.prototype.getAndCreateMethod = function (input) {
            if (input.btMethod[this.hashid]) {
                return input.btMethod[this.hashid];
            }
            else {
                var data = { index: 0 };
                if (!input)
                    return data;
                input.btMethod[this.hashid] = data;
                return input.btMethod[this.hashid];
            }
        };
        BaseNode.prototype.clearMethod = function (input) {
            if (input.btMethod[this.hashid]) {
                input.btMethod[this.hashid] = null;
            }
        };
        BaseNode.hashid = 1;
        return BaseNode;
    }());
    bt.BaseNode = BaseNode;
})(bt || (bt = {}));
var bt;
(function (bt) {
    var ErrorCode = (function () {
        function ErrorCode() {
        }
        ErrorCode.e1 = '子节点不存在';
        return ErrorCode;
    }());
    bt.ErrorCode = ErrorCode;
})(bt || (bt = {}));
var bt;
(function (bt) {
    var Action = (function (_super) {
        __extends(Action, _super);
        function Action() {
            _super.call(this);
            this.name = 'Action';
        }
        Action.prototype.setCondition = function (condition) {
            this.condition = condition;
            return this;
        };
        return Action;
    }(bt.BaseNode));
    bt.Action = Action;
})(bt || (bt = {}));
var bt;
(function (bt) {
    var Composite = (function (_super) {
        __extends(Composite, _super);
        function Composite() {
            _super.call(this);
            this.children = [];
        }
        Composite.prototype.setCondition = function (condition) {
            this.condition = condition;
            return this;
        };
        Composite.prototype.addNode = function (node) {
            this.children.push(node);
            return this;
        };
        Composite.prototype.clearMethod = function (input) {
            _super.prototype.clearMethod.call(this, input);
            var len = this.children.length;
            for (var idx = 0; idx < len; idx++) {
                var node = this.children[idx];
                node.clearMethod(input);
            }
        };
        return Composite;
    }(bt.BaseNode));
    bt.Composite = Composite;
})(bt || (bt = {}));
var bt;
(function (bt) {
    var Queue = (function (_super) {
        __extends(Queue, _super);
        function Queue() {
            _super.call(this);
            this.name = 'Queue';
        }
        Queue.create = function () {
            return new bt.Queue();
        };
        Queue.prototype.execute = function (input) {
            var len = this.children.length;
            if (len == 0)
                throw bt.ErrorCode.e1;
            var state = 0;
            var data = this.getAndCreateMethod(input);
            for (var idx = data.index; idx < len; idx++) {
                var node = this.children[idx];
                var nodestate = node.tick(input);
                if (nodestate == 2) {
                    data.index = idx;
                    state = 2;
                    break;
                }
                else {
                    node.clearMethod(input);
                }
            }
            if (state != 2) {
                data.index = 0;
            }
            return state;
        };
        return Queue;
    }(bt.Composite));
    bt.Queue = Queue;
})(bt || (bt = {}));
var bt;
(function (bt) {
    var Selector = (function (_super) {
        __extends(Selector, _super);
        function Selector() {
            _super.call(this);
            this.name = 'Selector';
        }
        Selector.create = function () {
            return new bt.Selector();
        };
        Selector.prototype.execute = function (input) {
            var len = this.children.length;
            if (len == 0)
                throw bt.ErrorCode.e1;
            var state = 1;
            var data = this.getAndCreateMethod(input);
            for (var idx = data.index; idx < len; idx++) {
                var node = this.children[idx];
                state = node.tick(input);
                if (state == 0) {
                    state = 0;
                    break;
                }
                else if (state == 2) {
                    data.index = idx;
                    state = 2;
                    break;
                }
                else {
                    node.clearMethod(input);
                }
            }
            if (state != 2) {
                data.index = 0;
            }
            return state;
        };
        return Selector;
    }(bt.Composite));
    bt.Selector = Selector;
})(bt || (bt = {}));
var bt;
(function (bt) {
    var Sequences = (function (_super) {
        __extends(Sequences, _super);
        function Sequences() {
            _super.call(this);
            this.name = 'Sequences';
        }
        Sequences.create = function () {
            return new bt.Sequences();
        };
        Sequences.prototype.execute = function (input) {
            var len = this.children.length;
            if (len == 0)
                throw bt.ErrorCode.e1;
            var state = 0;
            var data = this.getAndCreateMethod(input);
            for (var idx = data.index; idx < len; idx++) {
                var node = this.children[idx];
                state = node.tick(input);
                if (state == 2) {
                    data.index = idx;
                    state = 2;
                    break;
                }
                if (state == 1) {
                    node.clearMethod(input);
                    break;
                }
            }
            if (state != 2) {
                data.index = 0;
            }
            return state;
        };
        return Sequences;
    }(bt.Composite));
    bt.Sequences = Sequences;
})(bt || (bt = {}));
var bt;
(function (bt) {
    var ConditionComposite = (function () {
        function ConditionComposite() {
            this.children = [];
        }
        ConditionComposite.prototype.addCondition = function (node) {
            this.children.push(node);
            return this;
        };
        ConditionComposite.prototype.execute = function (input) {
            return true;
        };
        return ConditionComposite;
    }());
    bt.ConditionComposite = ConditionComposite;
})(bt || (bt = {}));
var bt;
(function (bt) {
    var ConditionDecorator = (function () {
        function ConditionDecorator() {
        }
        ConditionDecorator.prototype.execute = function (input) {
            return true;
        };
        ConditionDecorator.prototype.setChild = function (child) {
            this.child = child;
            return this;
        };
        return ConditionDecorator;
    }());
    bt.ConditionDecorator = ConditionDecorator;
})(bt || (bt = {}));
var bt;
(function (bt) {
    var ConditionInverter = (function (_super) {
        __extends(ConditionInverter, _super);
        function ConditionInverter() {
            _super.call(this);
        }
        ConditionInverter.create = function () {
            return new bt.ConditionInverter();
        };
        ConditionInverter.prototype.execute = function (input) {
            if (this.child) {
                return !this.child.execute(input);
            }
            return true;
        };
        return ConditionInverter;
    }(bt.ConditionDecorator));
    bt.ConditionInverter = ConditionInverter;
})(bt || (bt = {}));
var bt;
(function (bt) {
    var ConditionSelector = (function (_super) {
        __extends(ConditionSelector, _super);
        function ConditionSelector() {
            _super.call(this);
        }
        ConditionSelector.create = function () {
            return new bt.ConditionSelector();
        };
        ConditionSelector.prototype.execute = function (input) {
            var len = this.children.length;
            if (len == 0)
                return true;
            for (var idx = 0; idx < len; idx++) {
                var node = this.children[idx];
                var result = node.execute(input);
                if (result) {
                    return true;
                }
            }
            return false;
        };
        return ConditionSelector;
    }(bt.ConditionComposite));
    bt.ConditionSelector = ConditionSelector;
})(bt || (bt = {}));
var bt;
(function (bt) {
    var ConditionSequences = (function (_super) {
        __extends(ConditionSequences, _super);
        function ConditionSequences() {
            _super.call(this);
        }
        ConditionSequences.create = function () {
            return new bt.ConditionSequences();
        };
        ConditionSequences.prototype.execute = function (input) {
            var len = this.children.length;
            if (len == 0)
                return true;
            for (var idx = 0; idx < len; idx++) {
                var node = this.children[idx];
                var result = node.execute(input);
                if (result == false) {
                    return false;
                }
            }
            return true;
        };
        return ConditionSequences;
    }(bt.ConditionComposite));
    bt.ConditionSequences = ConditionSequences;
})(bt || (bt = {}));
var bt;
(function (bt) {
    var Decorator = (function (_super) {
        __extends(Decorator, _super);
        function Decorator() {
            _super.call(this);
        }
        Decorator.prototype.setCondition = function (condition) {
            this.condition = condition;
            return this;
        };
        Decorator.prototype.setChild = function (child) {
            this.child = child;
            return this;
        };
        return Decorator;
    }(bt.BaseNode));
    bt.Decorator = Decorator;
})(bt || (bt = {}));
var bt;
(function (bt) {
    var Inverter = (function (_super) {
        __extends(Inverter, _super);
        function Inverter() {
            _super.call(this);
            this.name = 'Inverter';
        }
        Inverter.create = function () {
            return new bt.Inverter();
        };
        Inverter.prototype.execute = function (input) {
            if (!this.child)
                throw bt.ErrorCode.e1;
            var state = this.child.tick(input);
            if (state == 1)
                state = 0;
            if (state == 0)
                state = 1;
            return state;
        };
        return Inverter;
    }(bt.Decorator));
    bt.Inverter = Inverter;
})(bt || (bt = {}));
var bt;
(function (bt) {
    var Repeater = (function (_super) {
        __extends(Repeater, _super);
        function Repeater() {
            _super.call(this);
            this.count = 1;
            this.name = 'Repeater';
        }
        Repeater.create = function (count) {
            var unit = new bt.Repeater();
            unit.count = Math.max(1, count || 1);
            return unit;
        };
        Repeater.prototype.execute = function (input) {
            if (!this.child)
                throw bt.ErrorCode.e1;
            var state = this.child.tick(input);
            if (state == 2) {
                return 2;
            }
            var data = this.getAndCreateMethod(input);
            data.curCount++;
            if (data.curCount >= this.count) {
                data.curCount = 0;
                return 0;
            }
            return 2;
        };
        Repeater.prototype.getAndCreateMethod = function (input) {
            if (input.btMethod[this.hashid]) {
                return input.btMethod[this.hashid];
            }
            else {
                var data = { curCount: 0 };
                if (!input)
                    return data;
                input.btMethod[this.hashid] = data;
                return input.btMethod[this.hashid];
            }
        };
        return Repeater;
    }(bt.Decorator));
    bt.Repeater = Repeater;
})(bt || (bt = {}));
var bt;
(function (bt) {
    var RepeatUntilFail = (function (_super) {
        __extends(RepeatUntilFail, _super);
        function RepeatUntilFail() {
            _super.call(this);
            this.name = 'RepeatUntilFail';
        }
        RepeatUntilFail.create = function () {
            return new bt.RepeatUntilFail();
        };
        RepeatUntilFail.prototype.execute = function (input) {
            if (!this.child)
                throw bt.ErrorCode.e1;
            var state = this.child.tick(input);
            if (state == 2) {
                return 2;
            }
            if (state == 1) {
                return 0;
            }
            return 2;
        };
        return RepeatUntilFail;
    }(bt.Decorator));
    bt.RepeatUntilFail = RepeatUntilFail;
})(bt || (bt = {}));
var bt;
(function (bt) {
    var RepeatUntilSuccess = (function (_super) {
        __extends(RepeatUntilSuccess, _super);
        function RepeatUntilSuccess() {
            _super.call(this);
            this.name = 'RepeatUntilSuccess';
        }
        RepeatUntilSuccess.create = function () {
            return new bt.RepeatUntilSuccess();
        };
        RepeatUntilSuccess.prototype.execute = function (input) {
            if (!this.child)
                throw bt.ErrorCode.e1;
            var state = this.child.tick(input);
            if (state == 2) {
                return 2;
            }
            if (state == 0) {
                return 0;
            }
            return 2;
        };
        return RepeatUntilSuccess;
    }(bt.Decorator));
    bt.RepeatUntilSuccess = RepeatUntilSuccess;
})(bt || (bt = {}));
var bt;
(function (bt) {
    var Succeeder = (function (_super) {
        __extends(Succeeder, _super);
        function Succeeder() {
            _super.call(this);
            this.name = 'Succeeder';
        }
        Succeeder.create = function () {
            return new bt.Succeeder();
        };
        Succeeder.prototype.execute = function (input) {
            if (!this.child)
                throw bt.ErrorCode.e1;
            var state = this.child.tick(input);
            if (state == 2) {
                return 2;
            }
            return 0;
        };
        return Succeeder;
    }(bt.Decorator));
    bt.Succeeder = Succeeder;
})(bt || (bt = {}));
module.exports = bt;

/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var ScreenManager = (function () {
    function ScreenManager() {
    }
    ScreenManager.captureScreen = function () {
        this.lastScreenshotTime = new Date().getTime();
        this.screenshot = images.captureScreen();
    };
    ScreenManager.matchImage = function (imgSpec) {
        if (imgSpec.alpha) {
            return this.matchImageEx(imgSpec);
        }
        var points = images.matchTemplate(this.screenshot, imgSpec.img, {
            threshold: 0.4,
            region: imgSpec.region
        }).points;
        return points.length > 0;
    };
    ScreenManager.matchImageEx = function (imgSpec) {
        var isMatch = images.matchTemplateEx(this.screenshot, imgSpec.img, {
            region: imgSpec.region,
            threshold: 0.4,
        });
        return isMatch;
    };
    ScreenManager.waitImage = function (imgSpec) {
        do {
            sleep(1000);
            this.screenshot = images.captureScreen();
            if (this.matchImage(imgSpec)) {
                break;
            }
        } while (1);
    };
    ScreenManager.recognizeImage = function (ic) {
        var r = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            r[_i - 1] = arguments[_i];
        }
        var clip = images.clip(this.screenshot, r[0], r[1], r[2], r[3]);
        var bestClass = ic.recognizeImage(clip);
        clip.recycle();
        return bestClass;
    };
    return ScreenManager;
}());
exports.default = ScreenManager;


/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.State = exports.StateMachine = void 0;
var State = (function () {
    function State() {
    }
    State.prototype.onEnter = function () {
    };
    State.prototype.onEntryFrom = function (state) {
    };
    State.prototype.onExit = function () {
    };
    State.prototype.onUpdate = function () {
    };
    return State;
}());
exports.State = State;
var StateMachine = (function () {
    function StateMachine(description) {
        this.stateName = 0;
        var startingStateName = description[StateMachine.STARTING_STATE];
        this.states = description[StateMachine.STATES];
        this.setState(startingStateName);
    }
    StateMachine.prototype.getState = function () {
        return this.states[this.stateName];
    };
    StateMachine.prototype.getAllStatesNames = function () {
        var keys = [];
        for (var key in this.states) {
            keys.push(key);
        }
        return keys;
    };
    StateMachine.prototype.setState = function (stateName) {
        if (stateName == this.stateName) {
            return;
        }
        var currentState = this.getState();
        if (currentState) {
            currentState.onExit();
        }
        this.previousStateName = this.stateName;
        this.stateName = stateName;
        var state = this.getState();
        state.onEnter();
        state.onEntryFrom(this.previousStateName);
    };
    StateMachine.prototype.onUpdate = function () {
        this.getState().onUpdate();
    };
    StateMachine.prototype.onExit = function () {
        this.getState().onExit();
    };
    StateMachine.STATES = 'states';
    StateMachine.STARTING_STATE = 'starting-state';
    return StateMachine;
}());
exports.StateMachine = StateMachine;


/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
/* WEBPACK VAR INJECTION */(function(bt) {
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var CallAction_1 = __webpack_require__(10);
var StatusChecker_1 = __webpack_require__(11);
var Fsm_1 = __webpack_require__(5);
var BaseState = (function (_super) {
    __extends(BaseState, _super);
    function BaseState() {
        var _this = _super.call(this) || this;
        _this.btBlackBoard = bt.BlackBoard.create();
        _this.btAction = bt.Sequences.create();
        _this.btAction.addNode(CallAction_1.default.create(function () {
            StatusChecker_1.PlayerStatusManager.updateChecker();
        }));
        return _this;
    }
    BaseState.prototype.addActions = function () {
        var _this = this;
        var actions = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            actions[_i] = arguments[_i];
        }
        actions.forEach(function (el) { return _this.btAction.addNode(el); });
    };
    BaseState.prototype.onEnter = function () {
    };
    BaseState.prototype.onEntryFrom = function (state) {
    };
    BaseState.prototype.onExit = function () {
    };
    BaseState.prototype.onUpdate = function () {
        this.btAction.tick(this.btBlackBoard);
    };
    return BaseState;
}(Fsm_1.State));
exports.default = BaseState;

/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(3)))

/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var Fsm_1 = __webpack_require__(5);
var StateNames_1 = __webpack_require__(8);
var LoadAssertState_1 = __webpack_require__(9);
var GameStatusBar_1 = __webpack_require__(12);
var EventBus_1 = __webpack_require__(1);
var EventNames_1 = __webpack_require__(0);
var GamingState_1 = __webpack_require__(13);
var ScreenManager_1 = __webpack_require__(4);
var App = (function () {
    function App() {
        var _this = this;
        this.isFreezing = false;
        setTimeout(function () { return _this.onUpdate(); }, 10);
        EventBus_1.default.on(EventNames_1.EventNames.ROLE_FREEZING, function (isFreezing) {
            _this.isFreezing = isFreezing;
        });
        EventBus_1.default.on(EventNames_1.EventNames.START, function () {
            _this.fsm.setState(StateNames_1.StateNames.GAMEING);
        });
        EventBus_1.default.on(EventNames_1.EventNames.LOAD_ASSETS_COMPLETE, function () {
            _this.fsm.setState(StateNames_1.StateNames.GAMEING);
        });
    }
    App.prototype.onUpdate = function () {
        var _this = this;
        ScreenManager_1.default.captureScreen();
        this.fsm.onUpdate();
        ScreenManager_1.default.screenshot.recycle();
        var deltaTime = new Date().getTime() - ScreenManager_1.default.lastScreenshotTime;
        setTimeout(function () { return _this.onUpdate(); }, Math.max(0, 500 - deltaTime));
    };
    App.prototype.onExit = function () {
        this.updateTimerId && clearInterval(this.updateTimerId);
        this.fsm.onExit();
    };
    App.startup = function () {
        var _a, _b;
        sleep(1000);
        images.requestScreenCapture(false);
        var app = new App();
        var statusBar = new GameStatusBar_1.default();
        var description = (_a = {},
            _a[Fsm_1.StateMachine.STARTING_STATE] = StateNames_1.StateNames.LOAD_ASSETS,
            _a[Fsm_1.StateMachine.STATES] = (_b = {},
                _b[StateNames_1.StateNames.LOAD_ASSETS] = new LoadAssertState_1.default(),
                _b[StateNames_1.StateNames.GAMEING] = new GamingState_1.default(),
                _b),
            _a);
        app.fsm = new Fsm_1.StateMachine(description);
        events.on('exit', function () {
            toast('脚本结束');
            app.onExit();
            statusBar.onExit();
        });
    };
    return App;
}());
App.startup();


/***/ }),
/* 8 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.StateNames = void 0;
var StateNames;
(function (StateNames) {
    StateNames[StateNames["DEFAULT"] = 0] = "DEFAULT";
    StateNames[StateNames["LOAD_ASSETS"] = 1] = "LOAD_ASSETS";
    StateNames[StateNames["GAMEING"] = 2] = "GAMEING";
})(StateNames = exports.StateNames || (exports.StateNames = {}));


/***/ }),
/* 9 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var Assets_1 = __webpack_require__(2);
var EventNames_1 = __webpack_require__(0);
var BaseState_1 = __webpack_require__(6);
var EventBus_1 = __webpack_require__(1);
var LoadAssertState = (function (_super) {
    __extends(LoadAssertState, _super);
    function LoadAssertState() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.URL = "http://192.168.1.128:3400/img/";
        return _this;
    }
    LoadAssertState.prototype.onEnter = function () {
        for (var key in Assets_1.Assets.images) {
            var spec = Assets_1.Assets.images[key];
            spec.img = images.load(this.URL + key + '.png');
            if (spec.region.length <= 2) {
                spec.region.push(spec.img.getWidth(), spec.img.getHeight());
            }
        }
        setTimeout(function () {
            EventBus_1.default.emit(EventNames_1.EventNames.LOAD_ASSETS_COMPLETE);
        }, 100);
    };
    return LoadAssertState;
}(BaseState_1.default));
exports.default = LoadAssertState;


/***/ }),
/* 10 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
/* WEBPACK VAR INJECTION */(function(bt) {
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var CallAction = (function (_super) {
    __extends(CallAction, _super);
    function CallAction(callback) {
        var _this = _super.call(this) || this;
        _this.callback = callback;
        return _this;
    }
    CallAction.create = function (callback) {
        return new CallAction(callback);
    };
    CallAction.prototype.execute = function (input) {
        var res = this.callback();
        return res === "undefined" ? 0 : res;
    };
    return CallAction;
}(bt.Action));
exports.default = CallAction;

/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(3)))

/***/ }),
/* 11 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.PlayerStatusManager = exports.PlayerStatus = void 0;
var Assets_1 = __webpack_require__(2);
var EventNames_1 = __webpack_require__(0);
var EventBus_1 = __webpack_require__(1);
var ScreenManager_1 = __webpack_require__(4);
var PlayerStatus;
(function (PlayerStatus) {
    PlayerStatus[PlayerStatus["IDLE"] = 0] = "IDLE";
    PlayerStatus[PlayerStatus["AUTO_RUN"] = 1] = "AUTO_RUN";
    PlayerStatus[PlayerStatus["FIGHTING"] = 2] = "FIGHTING";
})(PlayerStatus = exports.PlayerStatus || (exports.PlayerStatus = {}));
var StatusChecker = (function () {
    function StatusChecker(bindingStatus, imgSpec) {
        this.bindingStatus = bindingStatus;
        this.imgSpec = imgSpec;
        this.checkValue = 0;
        this.ic = ImageClassifiers.create("/sdcard/Pictures/tf/converted_tflite/model_unquant.tflite", "/sdcard/Pictures/tf/converted_tflite/labels.txt");
        this.checkValue = 0;
    }
    StatusChecker.prototype.onUpdate = function () {
        var status = ScreenManager_1.default.recognizeImage(this.ic, 940, 680, 120, 120);
        if (status == PlayerStatus[PlayerStatus.AUTO_RUN]) {
            return true;
        }
        return false;
    };
    return StatusChecker;
}());
var PlayerStatusManager = (function () {
    function PlayerStatusManager() {
    }
    PlayerStatusManager.updateChecker = function () {
        var _this = this;
        this.currentStatus = PlayerStatus.IDLE;
        this.statusCheckers.some(function (el) {
            var checked = el.onUpdate();
            if (checked) {
                _this.currentStatus = el.bindingStatus;
            }
            return checked;
        });
        this.updateStatusText();
    };
    PlayerStatusManager.updateStatusText = function () {
        if (this.previousStatus != this.currentStatus) {
            this.previousStatus = this.currentStatus;
            EventBus_1.default.emit(EventNames_1.EventNames.UPDATE_STATUS_TEXT, this.STATUS_TEXT[this.currentStatus]);
        }
    };
    PlayerStatusManager.STATUS_TEXT = [
        "空闲",
        "自动寻路中...",
        "自动战斗中..."
    ];
    PlayerStatusManager.previousStatus = PlayerStatus.IDLE;
    PlayerStatusManager.currentStatus = PlayerStatus.IDLE;
    PlayerStatusManager.statusCheckers = [
        new StatusChecker(PlayerStatus.AUTO_RUN, Assets_1.Assets.images.img_zi),
    ];
    return PlayerStatusManager;
}());
exports.PlayerStatusManager = PlayerStatusManager;


/***/ }),
/* 12 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var EventNames_1 = __webpack_require__(0);
var EventBus_1 = __webpack_require__(1);
var GameStatusBar = (function () {
    function GameStatusBar() {
        var _this = this;
        this.WID = 360;
        this.HEI = 35;
        var w = this.floatyWindow = floaty.rawWindow(new XML("<frame gravity=\"center\" bg=\"#77999999\" w=\"" + this.WID + "px\" h=\"" + this.HEI + "px\" paddingLeft=\"10px\">\n                <horizontal>\n                <text id=\"txtJob\" layout_weight=\"1\"></text>\n                <text id=\"txtStatus\" layout_weight=\"1\"></text>\n                </horizontal>\n            </frame>"));
        w.setPosition(device.width - this.WID, device.height - this.HEI);
        w.exitOnClose();
        w.txtJob.click(function () {
            EventBus_1.default.emit(EventNames_1.EventNames.SHOW_MENU_DIALOG);
        });
        EventBus_1.default.on(EventNames_1.EventNames.UPDATE_JOB_TEXT, function (txt, txtColor) {
            _this.setText(_this.floatyWindow.txtJob, "[" + txt + "]", txtColor || colors.argb(255, 225, 138, 2));
        });
        EventBus_1.default.on(EventNames_1.EventNames.UPDATE_STATUS_TEXT, function (txt, txtColor) {
            _this.setText(_this.floatyWindow.txtStatus, txt, txtColor);
        });
    }
    GameStatusBar.prototype.setText = function (component, txt, txtColor) {
        if (txtColor === void 0) { txtColor = colors.argb(255, 0, 255, 0); }
        ui.run(function () {
            component.setText(txt);
            component.setTextColor(txtColor);
        });
    };
    GameStatusBar.prototype.onExit = function () {
        this.floatyWindow.close();
    };
    return GameStatusBar;
}());
exports.default = GameStatusBar;


/***/ }),
/* 13 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var MoleAction_1 = __webpack_require__(14);
var EventNames_1 = __webpack_require__(0);
var BaseState_1 = __webpack_require__(6);
var EventBus_1 = __webpack_require__(1);
var GamingState = (function (_super) {
    __extends(GamingState, _super);
    function GamingState() {
        var _this = _super.call(this) || this;
        _this.addActions(MoleAction_1.default.create());
        return _this;
    }
    GamingState.prototype.onEnter = function () {
        EventBus_1.default.emit(EventNames_1.EventNames.UPDATE_JOB_TEXT, "游戏中");
        EventBus_1.default.emit(EventNames_1.EventNames.UPDATE_STATUS_TEXT, "空闲");
    };
    GamingState.prototype.onUpdate = function () {
        _super.prototype.onUpdate.call(this);
    };
    return GamingState;
}(BaseState_1.default));
exports.default = GamingState;


/***/ }),
/* 14 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
/* WEBPACK VAR INJECTION */(function(bt) {
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var Assets_1 = __webpack_require__(2);
var RootAutomatorWrapper_1 = __webpack_require__(15);
var ScreenManager_1 = __webpack_require__(4);
var Utils_1 = __webpack_require__(16);
var MoleAction = (function (_super) {
    __extends(MoleAction, _super);
    function MoleAction(moles) {
        var _this = _super.call(this) || this;
        _this.moles = moles;
        _this.moles = [
            Assets_1.Assets.images.img_skip,
            Assets_1.Assets.images.img_skip2,
            Assets_1.Assets.images.btn_quick_use,
        ];
        return _this;
    }
    MoleAction.create = function () {
        return new MoleAction();
    };
    MoleAction.prototype.execute = function (input) {
        return this.moles.some(function (el) {
            if (ScreenManager_1.default.matchImage(el)) {
                if (el.pt) {
                    RootAutomatorWrapper_1.default.click(el.pt);
                }
                else if (el.findbtn) {
                    var clicked = el.findbtn.points.some(function (pt) {
                        if (images.detectsColor(ScreenManager_1.default.screenshot, el.findbtn.color, pt[0], pt[1], 20)) {
                            return RootAutomatorWrapper_1.default.click(pt);
                        }
                    });
                    if (!clicked) {
                        RootAutomatorWrapper_1.default.click(el.findbtn.points[0]);
                    }
                }
                else {
                    RootAutomatorWrapper_1.default.click(Utils_1.default.getCenter(el.region));
                }
                return true;
            }
        }) ? 0 : 1;
    };
    return MoleAction;
}(bt.Action));
exports.default = MoleAction;

/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(3)))

/***/ }),
/* 15 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var RootAutomatorWrapper = (function () {
    function RootAutomatorWrapper() {
    }
    RootAutomatorWrapper.click = function (x, y) {
        if (typeof x == 'number') {
            this.ra.press(x, y, 150);
        }
        else if (x instanceof Array) {
            this.ra.press(x[0], x[1], 150);
        }
        else {
            this.ra.press(x.x, x.y, 150);
        }
    };
    RootAutomatorWrapper.ra = new RootAutomator();
    return RootAutomatorWrapper;
}());
exports.default = RootAutomatorWrapper;


/***/ }),
/* 16 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var Utils = (function () {
    function Utils() {
    }
    Utils.getCenter = function (rect) {
        return [rect[0] + Math.floor(rect[2] / 2), rect[1] + Math.floor(rect[3] / 2)];
    };
    Utils.dp2px = function (dp) {
        return dp * (280 / 160);
    };
    return Utils;
}());
exports.default = Utils;


/***/ })
/******/ ]);